package com.itheima.springmvc;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author fengqingayng
 * @version 1.0.0
 * @date 2019/7/6 22:23
 * @description
 **/
public class HelloController implements Controller {
    /**
     * Process the request and return a ModelAndView object which the DispatcherServlet
     * will render. A {@code null} return value is not an error: it indicates that
     * this object completed request processing itself and that there is therefore no
     * ModelAndView to render.
     *
     * @param request  current HTTP request
     * @param response current HTTP response
     * @return a ModelAndView to render, or {@code null} if handled directly
     * @throws Exception in case of errors
     */
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {


        ModelAndView view = new ModelAndView();

        /*封装数据结果*/
        view.addObject("result","service层返回的结果");

        /*设置试图名称*/
        view.setViewName("hello");



        return view;
    }
}
